<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<!-- Generated by Apache Maven Doxia at 2017-08-20 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Log4j Scala API &#x2013; Log4j Scala 2.10 API - Scala 2.10 wrapper for Log4j API</title>
		<link rel="stylesheet" href="./css/bootstrap.min.css" type="text/css" />
		<link rel="stylesheet" href="./css/site.css" type="text/css" />
		<script type="text/javascript" src="./js/jquery.min.js"></script>
		<script type="text/javascript" src="./js/bootstrap.min.js"></script>
		<script type="text/javascript" src="./js/prettify.min.js"></script>
		<script type="text/javascript" src="./js/site.js"></script>
		<meta name="Date-Revision-yyyymmdd" content="20170820" />
		<meta http-equiv="Content-Language" content="en" />
		
				</head>
	<body class="composite">
		<a href="https://logging.apache.org/">
			<img class="logo-left" src="./images/ls-logo.jpg" alt="Apache logging services logo" />
		</a>
		<img class="logo-right" src="./images/logo.png" alt="Apache log4j logo" />
		<div class="clear"></div>

		<div class="navbar">
			<div class="navbar-inner">
				<div class="container-fluid">
					<a class="brand" href="http://logging.apache.org/log4j/2.x/log4j-api-scala_2.10/">Scala 2.10 wrapper for Log4j API &trade;</a>
						<ul class="nav">
						<li>
					
				
				<a href="http://www.apache.org/" class="external" target="_blank" title="Apache">Apache</a>
			</li>
					<li>
									<a href="../../../" title="Logging Services">Logging Services</a>
			</li>
					<li>
									<a href="../index.html" title="Log4j">Log4j</a>
			</li>
		</ul>
				</div>
			</div>
		</div>

		<div class="container-fluid">
			<table class="layout-table">
				<tr>
					<td class="sidebar">
						<div class="well sidebar-nav">
										<ul class="nav nav-list">
		 														 <li class="nav-header">Component Documentation</li>
																																																																																																																																																									<li class="expanded">
									<a href="project-info.html" title="Component Information">Component Information</a>
										<ul>
																					<li class="none">
									<a href="dependencies.html" title="Dependencies">Dependencies</a>
					</li>
 																						<li class="none">
									<a href="dependency-info.html" title="Dependency Information">Dependency Information</a>
					</li>
 																						<li class="none">
									<a href="dependency-management.html" title="Dependency Management">Dependency Management</a>
					</li>
 																						<li class="none">
									<a href="distribution-management.html" title="Distribution Management">Distribution Management</a>
					</li>
 																							<li class="none active">
									<a href="index.html" title="About">About</a>
					</li>
 																	<!-- Removing overall project item Issue Management from component-specific menu -->
																	<!-- Removing overall project item Licenses from component-specific menu -->
																	<!-- Removing overall project item Mailing Lists from component-specific menu -->
																						<li class="none">
									<a href="plugin-management.html" title="Plugin Management">Plugin Management</a>
					</li>
 																						<li class="none">
									<a href="plugins.html" title="Plugins">Plugins</a>
					</li>
 																	<!-- Removing overall project item Source Code Management from component-specific menu -->
																						<li class="none">
									<a href="project-summary.html" title="Summary">Summary</a>
					</li>
 										</ul>
							</li>
 																																											<li class="collapsed">
									<a href="project-reports.html" title="Component Reports">Component Reports</a>
										</li>
 								</ul>
							</div>
						<div id="poweredBy">
															<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
				<img class="poweredBy" alt="Built by Maven" src="./images/maven-feather.png" />
			</a>
									</div>
					</td>
					<td class="content">
						<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
--><h1>Log4j Scala 2.10 API</h1>
<div class="section">
<h2><a name="Requirements"></a>Requirements</h2>
<p>Log4j Scala API for Scala 2.10 requires Log4j API, Java 7, the Scala runtime library, and the Scala reflection library. To use Log4j as a logging implementation, then Log4j Core must also be included. Instructions on using these dependencies are in the <a href="dependency-info.html">dependency information page</a>, and additional information is included in the <a href="../maven-artifacts.html">Log4j artifacts</a> page.</p></div>
<div class="section">
<h2><a name="Example_Usage"></a>Example Usage</h2>

<div>
<pre class="prettyprint linenums">
import org.apache.logging.log4j.scala.Logging
import org.apache.logging.log4j.Level

class MyClass extends BaseClass with Logging {
  def doStuff(): Unit = {
    logger.info(&quot;Doing stuff&quot;)
  }
  def doStuffWithLevel(level: Level): Unit = {
    logger(level, &quot;Doing stuff with arbitrary level&quot;)
  }
}
</pre></div></div>
<div class="section">
<h2><a name="Configuration"></a>Configuration</h2>
<p>Log4j Scala 2.10 API uses the standard <a href="../configuration.html">Log4j configuration</a> plugins. This supports XML, properties files, and a configuration builder DSL by default, and it optionally supports JSON and YAML formats with some additional Jackson dependencies.</p></div>
<div class="section">
<h2><a name="Substituting_Parameters"></a>Substituting Parameters</h2>
<p>In the Java API, parameters to a log message are interpolated using various strategies. In the Scala API, <a class="externalLink" href="http://docs.scala-lang.org/overviews/core/string-interpolation.html">string interpolation</a> is used instead. As all logger methods are implemented as macros, string construction and method invocations will only occur when logging is enabled for the given log level. For example:</p>

<div>
<pre class="prettyprint linenums">
logger.debug(s&quot;Logging in user ${user.getName} with birthday ${user.calcBirthday}&quot;)
</pre></div></div>
<div class="section">
<h2><a name="Logger_Names"></a>Logger Names</h2>
<p>Most logging implementations use a hierarchical scheme for matching logger names with logging configuration. In this scheme the logger name hierarchy is represented by &#x2018;.&#x2019; characters in the logger name, in a fashion very similar to the hierarchy used for Java/Scala package names. The <a href="scaladocs/index.html#org.apache.logging.log4j.scala.Logging"><tt>Logging</tt> trait</a> will automatically name the Logger accordingly to the class it is being used in.</p></div>
					</td>
				</tr>
			</table>
		</div>

		<div class="footer">
							<p>Copyright &copy; 1999-2017 <a class="external" href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</p>
				<p>Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the Apache Logging project logo are trademarks of The Apache Software Foundation.</p>
				<p>Site powered by <a class="external" href="http://getbootstrap.com/">Twitter Bootstrap</a>. Icons from <a class="external" href="http://glyphicons.com/">Glyphicons Free</a>.</p>
			</div>
		</div>
	</body>
</html>
